package com.gack.business.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gack.business.model.AdvertisingPush;
import com.gack.business.model.RequestModel;
import com.gack.business.service.AdvertisingPushServiceInterface;
import com.gack.helper.common.AjaxJson;
import com.gack.helper.common.abstractobj.ApiController;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(ApiController.ADVERTISITING_PUSTH)
public class AdvertisingPushController {
	@Autowired
	private AdvertisingPushServiceInterface advertisingPushService;
	
	@ApiOperation("保存或更新")
	@PostMapping("/saveOrUpdate")
	public AjaxJson saveOrUpdate(@RequestBody RequestModel requestModel) {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(advertisingPushService.saveOrUpdate(requestModel.getAdvertisingPush()));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败");
		}
		return ajaxJson;
	}
	
	@ApiOperation("移动端获取所有的的广告")
	@PostMapping("/getAdvertisingPuth")
	public AjaxJson getAdvertisingPuth() {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(advertisingPushService.getAdvertisingPuth());
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败");
		}
		return ajaxJson;
	}
	
	@ApiOperation("PC运营后台列表")
	@PostMapping("/getAllPush")
	public AjaxJson getAllPush() {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(advertisingPushService.getAllPush());
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败");
		}
		return ajaxJson;
	}

}
